<template>
  <div>
    <ul>
        <li><router-link to="/contacts/All_contacts">All_contacts</router-link></li>
        <li><router-link to="/contacts/Alice">Alice</router-link></li>
        <li><router-link to="/contacts/Bob">Bob</router-link></li>
    </ul>
    <button @click="showBtn">随机显示</button>
    <router-view></router-view>
    
  </div>
</template>

<script>
export default {
    data () {
        return {
            arr: ['all','alice','bob']      
        }
    },
    methods: {
        showBtn() {
            let random = Math.floor(Math.random() * this.arr.length)
            this.$router.push({
                name: this.arr[random]
            })
        }
    }
}
</script>

<style scoped>
a {
  margin-right: 5px;
}
.router-link-active {
  color: red;
}
</style>